package org.darkforest.ucenter.service.impl;

import org.darkforest.enums.MemberType;
import org.darkforest.model.Member;
import org.darkforest.model.MemberWithBLOBs;
import org.darkforest.ucenter.service.MemberService;
import org.darkforest.ucenter.service.MemberTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * MemberTypeServiceImpl
 * Created by Justin on 15/5/24.
 */
@Service
public class MemberTypeServiceImpl implements MemberTypeService {

    @Autowired
    @Qualifier("memberServiceImpl")
    private MemberService memberService;

    @Override
    public void setType(Integer memberId, MemberType memberType) {
        MemberWithBLOBs member = new MemberWithBLOBs();
        member.setMemberId(memberId);
        member.setMemberTypeEnum(memberType);

        memberService.updateMember(member);
    }

    @Override
    public MemberType getType(Integer memberId) {
        Member member = memberService.findMemberById(memberId);
        return member.getMemberTypeEnum();
    }
}
